//: Playground - noun: a place where people can play

import UIKit


// 如果对象没有实现Equatable 协议方法,系统不允许使用 == 进行判断,这是swift的严谨性
class A : Equatable {

    var name: String?
    
    static func == (lhs: A, rhs: A) -> Bool {
    
        return lhs.name == rhs.name
    }
}

//class B : Equatable {
//
//    var name : String?
//}

//func == (lhs: B, rhs: B) -> Bool {
//    
//    return lhs.name == rhs.name
//}

//

class B {
    
    var name : String?
}

extension B: Equatable {

    static func == (lhs: B, rhs: B) -> Bool {
        
        return lhs.name == rhs.name
    }
}

let classa = B();

classa.name = "1111"

let classb = B();

classb.name = "1111"

if classa == classb {
    
    print("7777")
} else {

    print("2222")
}


